package com.glh.javalogic.common;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import java.io.Serializable;

/**
 * author : 高磊华
 * e-mail : 984992087@qq.com
 * time   : 2018\6\9
 * desc   : activity的基类
 */

public abstract class BaseActivity extends AppCompatActivity {

    protected Context    context;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        context = this;
        setContentView(getContentResourseId());
        init();
    }

    protected abstract void init();

    protected abstract int getContentResourseId();

    public void JumpToActivity(Class<?> cls) {
        JumpToActivity(cls, null);
    }

    public void JumpToActivity(Class<?> cls, Object obj) {
        Intent intent = new Intent(this, cls);
        if (obj != null) {
            intent.putExtra("data", (Serializable) obj);
        }
        startActivity(intent);
    }

    public void JumpToActivity(Class<?> cls, Intent data) {
        Intent intent = new Intent(this, cls);
        if (data != null) {
            intent.putExtras(data);
        }
        startActivity(intent);
    }

}
